watch listを書き出すscript
from /programming-notes/watch listを書き出すscript
code:js
import {getProjectInfo} from "https://scrapbox.io/api/code/programming-notes/scrapboxのproject情報を一括して取得するUserScript/script.js";
import {lightFormat} from "https://scrapbox.io/api/code/takker/date-fns.min.js/script.js";
const watchListIds = Object.keys(JSON.parse(localStorage.getItem('projectsLastAccessed')));
const projects = await getProjectInfo(watchListIds);
// 作成日時順に並べてみる
const rankings = projects.sort((a,b) => a.created - b.created)
.flatMap(({name, displayName, created, publicVisible}) => !publicVisible ? [] : [`/${name}\t${
displayName.slice(0,10)
}${displayName.length > 10 ? "..." : ""}\t${lightFormat(new Date(created * 1000), "yyyy-MM-dd")}`]);
alert(rankings.join("\n"));
await navigator.clipboard.writeText("table:ranking(created)\n" + rankings.map(line => ${line}).join("\n"));
#watch_list
#2021-10-04 19:52:38